<template>
	<view class="">
		<view class="" v-if="goods_list.length>0">
			<view class="" v-for="(item,index) in goods_list">
				<view class="flex btw mb26" >
					<view class="flex_x">
						<image class="img120 br12" :src="item.goods.image_str" mode="">
						</image>
					</view>
					<view class="flex1 ml24 flex_col btw">
						<view class="sn2 c3 fw600 fs28">{{item.goods.title}}</view>
						<view class="flex_btw">
							<view class="c6 fw500 fs28" v-if="is_serve">儿童鞋</view>
							<view class="c9 fs24">x{{item.num}}</view>
						</view>
					</view>
					<view class="ml20 cfe4 fw500 pt10" v-if="!is_serve">
						<text class="fs24">￥</text>
						<text class="fs32">{{item.goods.price}}</text>
					</view>
				</view>
				<view class="cut_line mb24" v-if="is_serve"></view>
			</view>

			<view class="">
				<u-loading-icon :show='show_loading' text="加载中" size='26rpx' textSize="26rpx"></u-loading-icon>
			</view>
			<view class="flex_y mt24" v-if="list.length>3">
				<view class="open_close br8 flex_x" v-if="show" @click="openClose(1)">
					<view class="cf fw500 fs24 mr10">共{{count}}件</view>
					<u-icon name="arrow-down" color="#fff" size="26rpx"></u-icon>
				</view>
				<view class="open_close br8 flex_x" v-else @click="openClose(2)">
					<view class="cf fw500 fs24 mr10">收起</view>
					<u-icon name="arrow-up" color="#fff" size="26rpx"></u-icon>
				</view>
			</view>
		</view>
		<view class="" v-else>
			<u-empty mode="list" icon="http://cdn.uviewui.com/uview/empty/list.png" text='暂无商品~'>
			</u-empty>
		</view>
	</view>
</template>

<script>
	/*
	
	list 商品列表
	is_serve 是否显示分割线 隐藏价格 默认为false
	
	*/
	export default {
		props: {
			list: {
				typeOf: Array,
				default: []
			},
			count:{
				typeOf: Number,
				default: 0
			},
			is_serve: {
				typeOf: Boolean,
				default: false,
			}
			
		},
		components: {},
		data() {
			return {
				goods_lists: [], //商品总列表
				goods_list: [], //商品列表
				show_loading: false, //加载动画
				show: true, //展开收起
			}
		},
		onLoad() {

		},
		onShow() {

		},
		methods: {
			openClose(e) { //1展开 2收起
				if (e == 1) {
					this.show_loading = true
					setTimeout(() => {
						this.goods_list = this.goods_lists
						this.show_loading = false
					}, 400)
				} else {
					this.goods_list = this.goods_list.slice(0, 3)
				}
				this.show = !this.show
			}
		},
		computed: {

		},
		watch: {
			list: {
				handler(news, old) {
					this.goods_list = news.slice(0, 3)
					this.goods_lists = news
				},
				deep: true,
				immediate: true,
			},
		}
	}
</script>

<style lang="scss" scoped>
	.open_close {
		padding: 8upx 22upx;
		background: rgba(0, 0, 0, 0.2);
	}
</style>
